<template>
  <div class="no-print">
    <a-card class="info" title="员工档案">
      <!-- <template slot="extra">
      <template v-if="model.auditStatus==0">
        <a-button
            class="ruleButton"
            :ghost="true"
            type="primary"
            icon="edit"
            @click="handleEdit(model)"
            :disabled="isDisabledAuth('erpEmployeeFile:edit')"
        />
        <a-divider type="vertical"/>
        <a-popconfirm title="确定提交吗?" @confirm="() => handleSubmit(model.id)">
          <a-button type="primary" size="small" :disabled="isDisabledAuth('erpEmployeeFile:submit')">提交</a-button>
        </a-popconfirm>
      </template>
      <template v-if="model.auditStatus==1">
        <a-button type="primary" size="small" @click="handleAudit(model.id)"
                  :disabled="isDisabledAuth('erpEmployeeFile:audit')">审核
        </a-button>
      </template>
      <template v-if="model.auditStatus==2">
        <a-popconfirm title="确定反审吗?" @confirm="() => handleCounterTrial(model.id)">
          <a-button type="primary" size="small" :disabled="isDisabledAuth('erpEmployeeFile:counterTrial')">反审</a-button>
        </a-popconfirm>
      </template>
    </template> -->
      <a-row type="flex" justify="center">
        <a-col :span="24">
          <erp-employee-file-form ref="realForm" :disabled="true" normal></erp-employee-file-form>
          <!-- 流程历史跟踪 -->
          <!-- <common-flow-list v-if="model.bpmStatus !== '1'" :formData="formData"></common-flow-list> -->
        </a-col>
      </a-row>
    <!-- <erp-employee-file-modal ref="modalForm" @ok="modalFormOk"></erp-employee-file-modal>
    <audit-modal ref="auditModal" @ok="modalFormOk"></audit-modal> -->
    </a-card>

    <div style="text-align: center;margin-top: 15px;">
      <a-button v-print="'#printContent'" type="primary">打印</a-button>
    </div>
    <!-- class="print_style" id="printContent"  -->
    <!-- :formDataHistory="formData" 流程打印值 -->
    <ErpEmployeeFileFormPrint :formData="model" class="print_style" id="printContent" ></ErpEmployeeFileFormPrint>
  </div>
</template>

<script>

import { getAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ErpEmployeeFileForm from '@views/erp/files/employee/modules/ErpEmployeeFileForm'
import ErpEmployeeFileFormPrint from '@views/erp/files/employee/modules/ErpEmployeeFileFormPrint' // 打印组件
// import ErpEmployeeFileModal from '@views/erp/files/employee/modules/ErpEmployeeFileModal'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'
// import CommonFlowList from '@/views/components/CommonFlowList.vue' // 审批历史流程列表组件

export default {
  name: 'ErpEmployeeFileDetail',
  mixins: [JeecgListMixin, DisabledAuthFilterMixin],
  components: {
    ErpEmployeeFileForm,
    // CommonFlowList,
    ErpEmployeeFileFormPrint
    // ErpEmployeeFileModal,
  },
  data() {
    return {
      model: {},
      id: '',
      url: {
        queryById: '/api/erp/files/employee/erpEmployeeFile/queryById',
        delete: '/api/erp/files/employee/erpEmployeeFile/delete',
        submit: '/api/erp/files/employee/erpEmployeeFile/submit',
        revoke: '/api/erp/files/employee/erpEmployeeFile/revoke',
        counterTrial: '/api/erp/files/employee/erpEmployeeFile/counterTrial',
        audit: '/api/erp/files/employee/erpEmployeeFile/audit',
        overrule: '/api/erp/files/employee/erpEmployeeFile/overrule'
      },
      confirmLoading: false,
      iconStyle: { 'font-size': '20px' },
      disableMixinCreated: true
    }
  },
  props: {
    employeeId: String
  },
  watch: {
    employeeId: {
      handler: function(val) {
        console.log(val);
        this.getData(val)
      },
      immediate: true
    },
    // BUG4233 查看多人员工档案信息，信息数据被覆盖
    $route(to, from) {
      this.getData(to.query.id)
    }
  },
  methods: {
    getData(id) {
      getAction(this.url.queryById, { id }).then((res) => {
        if (res.success) {
          delete res.result.postChangeRecordList
          this.model = res.result;
          this.getPostList()
        }
      })
    },
    // 获取岗位信息
    getPostList() {
      var params = {
        isVirtual: '0', // 是否虚拟岗位为否
        postDataSource: 'employee', // 数据来源为在职员工档案
        isDuty: 'all',
        employeeId: this.model.id // 员工id
      }
      getAction('/api/erp/files/employee/erpEmployeePostChangeRecord/queryPostRecordByVo', params).then((res) => {
        if (res.success) {
          this.$set(this.model, 'postChangeRecordList', res.result)
          this.$refs.realForm.model = this.model;
        }
      })
    }
  }
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';

.info {
  /deep/ .ant-card-head-title {
    flex: none;
    margin-right: 20px;
  }

  /deep/ .ant-card-extra {
    flex: 1;
    float: left;
  }
}
.print_style{
  position: absolute;
  top: 0;
  z-index: -1111;
}
</style>
